<style lang="scss" scoped>
.el-breadcrumb__item:last-child ::v-deep {
        .el-breadcrumb__inner {
            color: #606266;
            font-weight: bold;
            cursor: default;
        }
    }
    .el-breadcrumb__item ::v-deep {
        .is-link {
            color: #aaa;
            font-weight: unset;
        }
        .is-link:hover {
            color: #409eff;
        }
    }
    // body{height:1000px;}
#footer{
  position:fixed;
  // background:#eee;
  // bottom:20px;
  // right:10px;
  // width:1660px;
  // height:100px;
}
</style>
<template>
    <div class="operate-exam-container">
        <div style="height: 30px;">
            <el-breadcrumb style="float: left;" separator="/">
                <el-breadcrumb-item :to="{ path: '/auditBudget' }">
                    <span @click="reback()" >{{ $t('approveBudget.auditedBudgetList') }}</span>
                </el-breadcrumb-item>
                <el-breadcrumb-item>{{ $t('approveBudget.audit')+'——'+ojbData.name }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <el-card
            style="padding: 0!important;"
            shadow="never"
            v-loading="loading"
            body-style="padding: 24px;" >
            <div style="height: 752px;overflow: scroll;">
              <div style="position:fixed;z-index:999;background-color:#f5f7fa;width:calc(100% - 324px)">
                <div style="display: flex;justify-content:space-between">
                  <h2 >{{$t('approveBudget.audit')+'——'+ojbData.name +'【' +ojbData.applySum+'】'+'元'}}</h2>
                  <el-button   type="text" @click="reback">{{$t('requirement.back')}}</el-button>
                </div>
                <hr style="border-top: 3px solid #eee;">
                <div style="display: flex;justify-content:space-between">
                  <h2 style="color:#101010">{{$t('approveBudget.appropriation')}}</h2>
                  <div style="color:#101010;margin-right:20px" >
                    <h2 >{{$t('approveBudget.totalAmount')}}{{valueDate+Number(value?value:0)}}元</h2>
                    <h2 >
                        {{$t('approveBudget.summation')}}：
                        <!-- {{value}} 元 -->
                        <!-- <el-input v-model="value" size="mini" style="width:120px" type="number" min='0' maxlength="3"></el-input>元 -->
                        <el-input-number style="width:160px" v-model="value" :precision="2" :step="0.1" :max='9999999999999' :min='0' size="small"></el-input-number>元
                    </h2>
                  </div>
                </div>
              </div>
              <projectDeclarationAddTab style="margin-top:140px" @changeTabe='clickTabe' @change-value='changeValues'  :compile='compile' :dataList='dataList'></projectDeclarationAddTab>
              <el-row style="margin-top:15px" type="flex" class="row-bg" justify="end">
                <el-button @click="reback" >{{$t('common.btn.cancel')}}</el-button>
                <!-- <el-button @click="save">{{$t('projectDeclara.save')}}</el-button> -->
                <el-button type="primary" @click="valueChange">{{$t('approveBudget.audit')}}</el-button>
              </el-row>
            </div>
        </el-card>
    </div>
</template>
<script>
import projectDeclarationAddTab from './projectDeclarationAddTab'
import projectApplicaApi from 'common/src/api/subjectCompetition/projectApplica';
export default {
  components: {
    projectDeclarationAddTab
  },
    props: {
        compile: {
            type: String,
            default: ''
        },
        dataList: {
            type: Object,
            default: () => {}
        },
        ojbData: {
            type: Object,
            default: () => {}
        }
    },
  data() {
    return {
      value: 0,
      valueDate: 0,
      formObjOne: {
        textarea: {
          remark: ''
        },
        list: []
      },
      formObjTow: {
        textarea: {
          remark: ''
        },
        list: []
      },
      formObjSan: {
        textarea: {
          remark: ''
        },
        list: []
      },
    };
  },
  created() {
    projectApplicaApi.getApproveSum(this.ojbData).then(res => {
      this.valueDate = res.data
    })
    if(this.dataList && this.dataList.approvedBudget) {
      this.value = this.dataList.approvedBudget
    } else {
      this.value = 0
    }
    
  },
  methods: {
    // 审核
    audit() {
      // this.formObjOne
      // this.formObjTow
      // this.formObjSan
      // let listOne = []
      // let listTow = []
      // let listSan = []
      // if (this.formObjOne.list.length > 0) {
      //   listOne = this.formObjOne.list.filter(el => el.approveBudget)
      // }
      // if (this.formObjTow.list.length > 0) {
      //   listTow = this.formObjTow.list.filter(el => el.approveBudget)
      // }
      // if (this.formObjSan.list.length > 0) {
      //   listSan = this.formObjSan.list.filter(el => el.approveBudget)
      // }
      // if (listOne.length > 0 || listTow.length > 0 || listSan.length > 0) {
        // let list = listOne.concat(listTow,listSan)
          let obj = {
          id: this.ojbData.id,
          approvedBudget: this.value,
          budgetEntityList: []
        }
        projectApplicaApi.postApproveBudget(obj).then(res => {
          this.$message.success(this.$t('internship.successfully'));
          this.reback()
        })
         
        
      // } 
      // else {
      //   return this.$message.warning('请确认需要审核的金额是否填写')
      // }
    },
    valueChange(){
      let reg = /^(0|([1-9]\d*))(\.\d{1,2})?$/;
      if(!reg.test(this.value)) {
        return this.$message.warning('合计金额需大于等于0，且最多保留2位小数')
      } else if(this.value && this.value.length > 13) {
        return this.$message.warning('合计金额不能超过13位数字')
      } else {
        this.audit()
      }
    },
 
    // 保存
    save() {},
    changeValues(data) {
      // this.value = data
    },
    clickTabe(dataOne, dataTow, dataSan) {
      this.formObjOne = dataOne
      this.formObjTow = dataTow
      this.formObjSan = dataSan
    },
    reback() {
        this.$emit('change-exam')
    },
  }
};
</script>